# #g++  $^ -o $@ -L./mylib/lib/ -lbundle -lpthread -ljsoncpp -lstdc++fs -std=c++17

cmake_minimum_required(VERSION 3.25)  
set(CMAKE_CXX_STANDARD 17)  
set(CMAKE_CXX_STANDARD_REQUIRED True)  
  
project(cloudServer)  
  
# 查找 libjsoncpp  
find_library(JSONCPP_LIBRARY NAMES libjsoncpp.so.1.7.4 PATHS /usr/lib/x86_64-linux-gnu)  
if(NOT JSONCPP_LIBRARY)  
    message(FATAL_ERROR "libjsoncpp.so.1.7.4 not found")  
endif()  
  
# 查找 libbundle  
find_library(BUNDLE_LIBRARY NAMES libbundle.a PATHS /home/lhr/linux/cloud_backup/server/mylib/lib)  
if(NOT BUNDLE_LIBRARY)  
    message(FATAL_ERROR "libbundle.a not found")  
endif()  
  
# 添加可执行文件  
add_executable(cloudServer cloudServer.cpp)  

# 为特定目标设置输出目录
set_target_properties(cloudServer PROPERTIES  
#RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/my_bin  
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../  
)

# 链接库  
target_link_libraries(cloudServer  
    PRIVATE  
    ${JSONCPP_LIBRARY}  
    ${BUNDLE_LIBRARY}  
    pthread  
    stdc++fs
)  
  
# 注意：stdc++fs 不需要显式链接，它是 C++17 标准的一部分